<?php $this->context->layout = 'fullout'; ?>
<?= \common\widgets\Asset::widget(['type'=>['viewer']])?>
<div style="display: flex">
    <?=$this->params['leftHtml']?>
    <div  style="width: 89.7%">
        <div class="ui-layout-center">
            <div class="container-div">
                <div class="row">
                    <div class="col-sm-12 search-collapse">
                        <form id="role-form">
                            <input type="hidden" name="structId" id="structId" value="">
                            <div class="select-list">
                                <ul>
                                    <li><?= \common\widgets\FormInput::widget(['name'=>'input|名称','extend'=>['name'=>'like[name]']])?></li>
                                    <li><?= \common\widgets\FormInput::widget(['name'=>'select|状态','extend'=>['name'=>'where[status]','value'=>'','place'=>'所有']])?></li>
                                    <li>
                                        <?= $this->render('/iframe',['name'=>'searchbtn|搜索'])?>
                                        <?= $this->render('/iframe',['name'=>'resetbtn|重置'])?>
                                    </li>
                                </ul>
                            </div>
                        </form>
                    </div>
                    <div class="btn-group-sm" id="toolbar" role="group">
                        <?= $this->render('/iframe',['name'=>'addbtn','extend'=>['tab'=>1]])?>
                        <?= $this->render('/iframe',['name'=>'editbtn','extend'=>['tab'=>1]])?>
                    </div>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<?php $this->beginBlock('script'); ?>
<script>
    bootUrl.createUrl = decodeURIComponent("<?=\yii\helpers\Url::toRoute(['list-add','id'=>'{id}'])?>")
    bootUrl.updateUrl= decodeURIComponent("<?=\yii\helpers\Url::toRoute(['list-edit','id'=>'{id}'])?>");
    getUserList();
    function getUserList() {
        bootUrl.url = "<?=\yii\helpers\Url::toRoute('list')?>"

        var options = {
            modalName: "权益列表",
            columns: [
                {field: 'id', title: 'ID', align: 'center', sortable: true,visible: false},
                {field: 'name', align: 'center', title: '名称'},
                {field: 'c_id', align: 'center', title: '分类名称'},
                {
                    field: 'main_img',
                    title: '主图',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value,null,null,'slide',row.id,'main_img');
                    }
                },
                {
                    field: 'img',
                    title: '详情图',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value,null,null,'slide',row.id,'img');
                    }
                },
                {
                    field: 'address',
                    title: '地址',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value,10);
                    }
                },
                {field: 'mobile', title: '手机号'},
                {
                    field: 'feature',
                    title: '特色',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value,10);
                    }
                },
                {
                    field: 'trait',
                    title: '特点',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value,10);
                    }
                },
                {field: 'sort', align: 'center', title: '排序'},
                {
                    title: '精品',
                    field: 'is_boutique',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.view.statusTools(row,true,['关闭','启用'],'is_boutique');
                    }
                },
                {
                    title: '状态',
                    field: 'status',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.view.statusTools(row,true);
                    }
                },
                {field: 'create_time', title: '创建时间', align: 'center', sortable: true,visible: false},
                {field: 'update_time', title: '更新时间', align: 'center', sortable: true},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return '<?=$this->render("/iframe",["name"=>"formopbtn","extend"=>["type"=>["edittab","delete"],"rowId"=>"row.id"]])?>';
                    }
                }
            ],
            onPostBody:function (data) {
                for (let i = 0; i < data.length; i++) {
                    if(data[i].main_img){
                        new Viewer(document.getElementById('main_imgpts_'+data[i].id),{navbar:false,title:false});
                    }
                    if(data[i].img){
                        new Viewer(document.getElementById('imgpts_'+data[i].id),{navbar:false,title:false});
                    }
                }
            }
        };
        $.table.init(options);
    }
</script>
<?php $this->endBlock(); ?>

